package com.nyist.diseasepreventionserver.converter;

import com.nyist.diseasepreventionserver.VO.UserListBeforeVO;
import com.nyist.diseasepreventionserver.VO.UserListVO;
import com.nyist.diseasepreventionserver.common.ServerResponse;
import com.nyist.diseasepreventionserver.dto.UserDTO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.List;

public class UserDTOPage2UserListBeforeVO {
    public static UserListBeforeVO convert(Page<UserDTO> userDTOPage){
        Pageable pageable = userDTOPage.getPageable();
        List<UserListVO> result = UserDTOPage2UserListVOConverter.convert(userDTOPage.getContent());
        UserListBeforeVO userListBeforeVO = new UserListBeforeVO();
        userListBeforeVO.setContent(result);
        userListBeforeVO.setPageable(pageable);
        userListBeforeVO.setTotalElements(userDTOPage.getTotalElements());
        userListBeforeVO.setLast(userDTOPage.isLast());
        userListBeforeVO.setTotalPages(userDTOPage.getTotalPages());
        userListBeforeVO.setNumber(userDTOPage.getNumber());
        userListBeforeVO.setSize(userDTOPage.getSize());
        userListBeforeVO.setFirst(userDTOPage.isFirst());
        userListBeforeVO.setSort(userDTOPage.getSort());
        userListBeforeVO.setNumberOfElements(userDTOPage.getNumberOfElements());
        userListBeforeVO.setEmpty(userDTOPage.isEmpty());
        return userListBeforeVO;
    }
}
